home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
gnat1792.zip
/
gnat179b
/
t-adainc
/
s-tassta.adb
< prev
next >
Wrap
Text File
|
1994-05-19
|
43KB
|
1,296 lines
------------------------------------------------------------------------------
-- --
-- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . S T A G E S --
-- --
-- B o d y --
-- --
-- $Revision: 1.12 $ --
-- --
-- Copyright (c) 1991,1992,1993, FSU, All Rights Reserved --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU Library General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. GNARL is distributed in the hope that it will be use- --
-- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- --
-- eral Library Public License for more details. You should have received --
-- a copy of the GNU Library General Public License along with GNARL; see --
-- file COPYING. If not, write to the Free Software Foundation, 675 Mass --
-- Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
with System.Compiler_Exceptions;
-- Used for, Compiler_Exceptions.Notify_Exception
-- The following two packages are not part of the GNARL proper. They
-- provide access to a compiler-specific per-task data area.
with System.Task_Soft_Links;
-- Used for, Abort_Defer, Abort_Undefer, Get_TSD_Address
-- These are procedure pointers to non-tasking routines that use
-- task specific data. In the absense of tasking, these routines
-- refer to global data. In the presense of tasking, they must be
-- replaced with pointers to task-specific versions.
with System.Tasking_Specific_Data;
-- Used for, Create_TSD, Destroy_TSD
-- This package provides initialization routines for task specific data.
-- The GNARL must call these to be sure that all non-tasking
-- Ada constructs will work.
with System.Error_Reporting;
-- Used for, Error_Reporting.Assert
with System.Tasking.Abortion;
-- Used for, Abortion.Defer_Abortion,
-- Abortion.Undefer_Abortion
-- Abortion.Abort_Dependents
-- Abortion.Abort_To_Level
with System.Tasking.Rendezvous;
-- Uses for, Rendezvous.Complete
with System.Tasking.Runtime_Types;
-- Used for, Runtime_Types.ATCB_Ptr,
-- Runtime_Types.ATCB_To_ID,
-- Runtime_Types.ID_To_ATCB,
-- Runtime_Types.ATCB_To_Address
-- Runtime_Types."<",
-- Runtime_Types.">=",
-- Runtime_Types."=",
-- Runtime_Types."/=",
-- Runtime_Types.Task_Stage
-- Runtime_Types.Accepting_State
-- Runtime_Types.All_Tasks_List
-- Runtime_Types.Ada_Task_Control_Block
-- Runtime_Types.Task_Error
-- Runtime_Types.ATCB_Init
-- Runtime_Types.Await_Dependents
-- Runtime_Types.Vulnerable_Complete_Activation
with System.Task_Memory;
-- Used for, Task_Memory.Low_Level_New,
-- Task_Memory.Unsafe_Low_Level_New,
-- Task_Memory.Low_Level_Free
with System.Task_Primitives; use System.Task_Primitives;
with Unchecked_Conversion;
pragma Elaborate_All (System.Tasking.Rendezvous);
pragma Elaborate_All (System.Tasking.Runtime_Types);
pragma Elaborate_All (System.Task_Primitives);
pragma Elaborate_All (System.Tasking.Abortion);
pragma Elaborate_All (System.Error_Reporting);
pragma Elaborate_All (System.Compiler_Exceptions);
pragma Elaborate_All (System.Task_Memory);
pragma Elaborate_All (System.Task_Soft_Links);
-- This must be elaborated first, to prevent its initialization of
-- the global procedure pointers from overwriting the pointers installed
-- by Stages.
package body System.Tasking.Stages is
function ID_To_ATCB (ID : Task_ID) return Runtime_Types.ATCB_Ptr
renames Tasking.Runtime_Types.ID_To_ATCB;
function ATCB_To_ID (Ptr : Runtime_Types.ATCB_Ptr) return Task_ID
renames Runtime_Types.ATCB_To_ID;
-- Could use "use type" for the following declarations ???
function "=" (L, R : Runtime_Types.ATCB_Ptr) return Boolean
renames Runtime_Types."=";
function "=" (L, R : Runtime_Types.Task_Stage) return Boolean
renames Runtime_Types."=";
function ">=" (L, R : Runtime_Types.Task_Stage) return Boolean
renames Runtime_Types.">=";
function "<" (L, R : Runtime_Types.Task_Stage) return Boolean
renames Runtime_Types."<";
function "=" (L, R : Runtime_Types.Accepting_State) return Boolean
renames Runtime_Types."=";
procedure Defer_Abortion renames Abortion.Defer_Abortion;
procedure Undefer_Abortion renames Abortion.Undefer_Abortion;
function Activation_to_ATCB is new
Unchecked_Conversion (Activation_Chain, Runtime_Types.ATCB_Ptr);
function ATCB_to_Activation is new
Unchecked_Conversion (Runtime_Types.ATCB_Ptr, Activation_Chain);
-----------------------------
-- ATCB related operations --
-----------------------------
-- The TCB contains a variable size array whose dope vector must be
-- initialized. This is too complex (and changes too much with changes
-- in the TCB record) to do explicitely, so a record of the correct size
-- is declared here and copied into the newly allocated storage.
-- Discriminant checking is disabled to prevent the discriminant in the
-- newly created record from being checked before a legal value is
-- assigned to it.
-- How is discriminant checking disabled, I see no pragma Suppress ???
procedure Initialize_ATCB
(T : Runtime_Types.ATCB_Ptr;
Init : Runtime_Types.ATCB_Init);
-- Initialize fields of a TCB and link into global TCB structures
function New_ATCB
(Init : Runtime_Types.ATCB_Init)
return Runtime_Types.ATCB_Ptr;
-- New_ATCB creates a new ATCB using the low level allocation routines
-- (essentially a protected version of malloc()). This is done because
-- the new operator can be changed by the user, and may involve
-- allocation from pools (which would limit the number of tasks), might
-- block on insufficiant memory, or might fragment the user's heap
-- behind his back.
function Unsafe_New_ATCB
(Init : Runtime_Types.ATCB_Init)
return Runtime_Types.ATCB_Ptr;
-- This creates a new ATCB using unprotected low level allocation routines
-- (essentially malloc()). This is done for allocating the ATCB for the
-- initial task, since this must be done before initializing the low
-- level tasking, and locks (and hence protected Low_Level_New) cannot
-- be used until it is.
procedure Free_ATCB (T : in out Runtime_Types.ATCB_Ptr);
-- Release storage of a previously allocated ATCB
-----------------------------
-- Other Local Subprograms --
-----------------------------
procedure Task_Wrapper (Arg : System.Address);
-- Need documentation for this subprogram ???
procedure Terminate_Dependents (ML : Master_ID := Master_ID'First);
-- Terminate all dependent tasks of given master level
procedure Vulnerable_Complete_Task;
-- Need documentation for this subprogram ???
procedure Pop_Master;
-- Need documentation for this subprogram ???
procedure Close_Entries (Target : Task_ID);
-- Close entries, Purge entry queues called by Task_Stages.Complete.
-- T.Stage must be Completing before this is c